<?php
class CBaseURLHandler
{
	protected $routes;
	public function __construct($config=null)
	{
		$this->routes=new CMap();
	}
	
	public function init($config=null)
	{
		
	}	
	
	public function setRoutes($routes)
	{
		$this->routes=$routes;
	}
	
	public function findRoute($requestURI)
	{
		preg_match('/ctlr_(?P<controller>[\w\d_,-.]+)-act_(?P<method>[\w\d_,-.]+)/', $requestURI, $matches);		
		if(isset($matches[0]))
		{
			return $this->routes->itemAt($matches[0]);
		} 
		else
		{
			$url_path = parse_url($requestURI, PHP_URL_PATH);
			$parts = explode('/', $url_path);
			$last = end($parts);
			return $this->routes->itemAt($last);
		}
	
	}
	
	
	
}